package com.ddf.controller;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

@Controller
@RequestMapping("/PathVariableRestDemo")
public class PathVariableRestDemo {
	private Logger log = LoggerFactory.getLogger(this.getClass());
	private static final String SUCCESS = "success";
	
	@RequestMapping("/testPathVariable/{userName}")
	public String testPathVariable(@PathVariable String userName) {
		log.info("testPathVariable userName :" + userName);
		return SUCCESS;
	}
	
	/**
	 * 这种好像不可以
	 * @param userName
	 * @param age
	 * @return
	 */
	@RequestMapping("/testPathVariable2/{userName}/{age}")
	public String testPathVariable2(@PathVariable String userName, @PathVariable
			 Integer age) {
		log.info("testPathVariable2 userName :" + userName + ","
				+ "age:" + age);
		return SUCCESS;
	}
	
	@RequestMapping(value = "/testRestMethodPost/{id}", method=RequestMethod.POST)
	public String testRestMethodPost(@PathVariable Integer id) {
		log.info("POST : testRestMethodPost ID :" + id);
		return SUCCESS;
	}
	
	@RequestMapping(value = "/testRestMethodDelete/{id}", method=RequestMethod.DELETE)
	public String testRestMethodDelete(@PathVariable Integer id) {
		log.info("DELETE : testRestMethodDelete ID :" + id);
		return SUCCESS;
	}
}
